<?
function get_url_contents($url)
{
    $cookie = "/tmp/baidu.cookie";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_REFERER, "http://www.baidu.com/");   //构造来路
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie);
    curl_setopt( $ch, CURLOPT_HEADER, 0);
//    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2 GTB5");
    $result =  curl_exec($ch);
    curl_close($ch);
    unset($ch);
    return $result;
}

    $url = $_POST["url"];
    $html = null;
    if($url) {
        $html = get_url_contents($url);
    }
    echo $html;
?>
